package uk.ac.ebi.curtain.configuration;

import java.io.File;

import javolution.util.FastList;
import uk.ac.ebi.curtain.utils.data.FileType;
import uk.ac.ebi.curtain.utils.data.ReadType;
import uk.ac.ebi.curtain.utils.file.FileInfo;

public class ArumentHelper implements ICurtainArgumentParserCallback{
	private CurtainInputArguments curtArg;
	private String pipelineType = null;
	
	public ArumentHelper() {
		this.curtArg = new CurtainInputArguments();
	}
	
	public CurtainInputArguments getCurtainArg() {
		return curtArg;
	}

	@Override
	public void addContigFile(FileType type, File... fileArr) {
		for(File f : fileArr){
			this.curtArg.addFile(new FileInfo(f,type,ReadType.Contig));
		}
	}

	@Override
	public void addMapViewFile(String category,FileType fType, ReadType rType,File... fileArr) {
		for(File f : fileArr){
			this.curtArg.addFile(category.toString(),new FileInfo(f,fType,rType));
		}
	}

	@Override
	public void addReadFile(String category, FileType fType,ReadType rType, File... fileArr) {
		for(File f : fileArr){
			this.curtArg.addFile(category,new FileInfo(f,fType,rType));
		}
	}

	public void printHelp(int status, String msg) {
		System.err.println(msg);
		if(status > 0){
			exit(status);
		}
	}

	public void exit(int status) {
		System.exit(status);
	}

	@Override
	public void setInsertLength(String catId, Integer insertLength) {
		this.curtArg.addInsertLength(catId, insertLength);
	}

	@Override
	public void setInsertLengthSd(String id, Integer sd) {
		this.curtArg.addInsertLengthSd(id, sd);
	}

	@Override
	public void setKmer(Integer kmer) {
		this.curtArg.setKmer(kmer);
	}
	
	@Override
	public void setMaxPartialCount(String cat, Integer count) {
		this.curtArg.setMaxPartialCount(cat, count);
	}

	@Override
	public void setMinPairCount(String cat, Integer count) {
		this.curtArg.setMinPairCount(cat,count);
	}	
	
	@Override
	public void setMaxPairCount(String cat, Integer count) {
		this.curtArg.setMaxPairCount(cat,count);
	}

	@Override
	public void setStartpoint(String startPoint) {
		this.curtArg.setStartpoint(startPoint);
	}

	@Override
	public void setWorkingDirectory(File workingDir) {
		this.curtArg.setWorkingDir(workingDir);
	}

	public void addBatchScope(Integer start, Integer end) {
		FastList<Integer> iList = new FastList<Integer>();
		for(int i = start; i <= end; ++i){
			iList.add(i);
		}
		this.curtArg.getBatchList().addAll(iList);
	}

	@Override
	public void setIteration(Integer iteration) {
		this.curtArg.setCurtainIteration(iteration);
	}

	@Override
	public void setUseContigInput(boolean b) {
		this.curtArg.setUseContigInput(b);
	}

	@Override
	public void setDistanceinfo(boolean b) {
		this.curtArg.setDistanceInfo(b);
	}

	@Override
	public void setPipelineType(String pipeline) {
		this.pipelineType = pipeline;
	}
	
	public String getPipelineType() {
		return this.pipelineType;
	}

	@Override
	public void setVelvetMinPairCount(Integer value) {
		this.curtArg.setVelvetMinPairCount(value);
	}

	@Override
	public void setFilterCovMax(Integer maxCov) {
		this.curtArg.setFilterCovMax(maxCov);
	}
	@Override
	public void setFilterCovMin(Integer minCov) {
		this.curtArg.setFilterCovMin(minCov);
		
	}

	@Override
	public void setVelvetForce(boolean b) {
		this.curtArg.getVelvetForce().set(b);
	}

	@Override
	public void setVelvetUnpaired(boolean b) {
		this.curtArg.getVelvetUnpaired().set(b);
	}

	@Override
	public void setVelvetCoverageCalculation(boolean b) {
		this.curtArg.getVelvetCoverageCalc().set(b);
	}
	
}